import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/blog",
    name: "blog",
    component: () => import(/* webpackChunkName: "blog" */ "../views/Blog"),
  },
  {
    path: "/blog/post",
    name: "blog-post",
    component: () =>
      import(/* webpackChunkName: "blog-post" */ "../views/Blog/Post"),
  },
  {
    path: "/news",
    name: "news",
    component: () => import(/* webpackChunkName: "news" */ "../views/News"),
  },
  {
    path: "/news/detail",
    name: "news-detail",
    component: () =>
      import(/* webpackChunkName: "news-detail" */ "../views/News/Detail"),
  },
  {
    path: "/question",
    name: "question",
    component: () =>
      import(/* webpackChunkName: "question" */ "../views/Question"),
  },
  {
    path: "/question/new",
    name: "question-new",
    component: () =>
      import(/* webpackChunkName: "question-new" */ "../views/Question/New"),
  },
  {
    path: "/user",
    name: "user",
    component: () => import(/* webpackChunkName: "user" */ "../views/User"),
    children: [
      {
        path: "",
        redirect: { name: "user-profile" },
      },
      {
        path: "profile",
        alias: "profile",
        name: "user-profile",
        component: () => import("../views/User/Profile"),
      },
      {
        path: "myanswer",
        name: "user-myanswer",
        component: () => import("../views/User/MyAnswer"),
      },
      {
        path: "myquestion",
        name: "user-myquestion",
        component: () => import("../views/User/MyQuestion"),
      },
    ],
  },
];

const router = new VueRouter({
  mode: "history",
  routes,
});

export default router;
